<!DOCTYPE HTML>
<html>
<head>
    <title>Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content=""/>
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <!-- Bootstrap Core CSS -->
    <link href="/css/bootstrap.css" rel='stylesheet' type='text/css'/>
    <!-- Custom CSS -->
    <link href="/css/style.css" rel='stylesheet' type='text/css'/>
    <!-- font CSS -->
    <!-- font-awesome icons -->
    <link href="/css/font-awesome.css" rel="stylesheet">
    <!-- //font-awesome icons -->
    <!-- js-->
    <script src="/js/jquery-1.11.1.min.js"></script>
    <script src="/js/modernizr.custom.js"></script>
    <!--webfonts-->
    <link href='https://fonts.googleapis.com/css?family=Roboto+Condensed:400,300,300italic,400italic,700,700italic'
          rel='stylesheet' type='text/css'>
    <!--//webfonts-->
    <!--animate-->
    <link href="/css/animate.css" rel="stylesheet" type="text/css" media="all">
    <script src="/js/wow.min.js"></script>
    <script>
        new WOW().init();
    </script>
    <!--//end-animate-->
    <!-- chart -->
    <script src="/js/Chart.js"></script>
    <!-- //chart -->
    <!--Calender-->
    <!--<link rel="stylesheet" href="css/clndr.css" type="text/css" />-->
    <script src="/js/underscore-min.js" type="text/javascript"></script>
    <script src="/js/moment-2.2.1.js" type="text/javascript"></script>
    <!--<script src="/js/clndr.js" type="text/javascript"></script>-->
    <!--<script src="/js/site.js" type="text/javascript"></script>-->
    <!--End Calender-->
    <!-- Metis Menu -->
    <script src="/js/metisMenu.min.js"></script>
    <script src="/js/custom.js"></script>
    <link href="/css/custom.css" rel="stylesheet">
    <!--//Metis Menu -->
</head>
<body class="cbp-spmenu-push">
<div class="main-content">
    <!--left-fixed -navigation-->
    <div class=" sidebar" role="navigation">
        <div class="navbar-collapse">
            <nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
                <ul class="nav" id="side-menu">
                    <li>
                        <a href="/index" class="active"><i class="fa fa-home nav_icon"></i>首页</a>
                    </li>
                    <li>
                        <a href="/access" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>门禁管理</a>
                    </li>
                    <li>
                        <a href="/user" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>用户管理</a>
                    </li>
                    <li>
                        <a href="/space" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>车位管理</a>
                    </li>
                    <li>
                        <a href="/car" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>车辆管理</a>
                    </li>
                    <li>
                        <a href="/community" class="active" style="color:#fff"><i
                                class="fa fa-home nav_icon"></i>小区管理</a>
                    </li>
                    <li>
                        <a href="/charges" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>费率管理</a>
                    </li>
                    <li>
                        <a href="/order" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>订单管理</a>
                    </li>
                    <li>
                        <a href="/appointment" class="active" style="color:#fff"><i class="fa fa-home nav_icon"></i>预约管理</a>
                    </li>
                </ul>
                <!-- //sidebar-collapse -->
            </nav>
        </div>
    </div>
    <!--left-fixed -navigation-->
    <!-- header-starts -->
    <div class="sticky-header header-section ">
        <div class="header-left">
            <!--toggle button start-->
            <button id="showLeftPush"><i class="fa fa-bars"></i></button>
            <!--toggle button end-->
            <!--logo -->
            <div class="logo">
                <a href="/index">
                    <h1>智慧停车云平台</h1>
                    <span>陈福兵的毕业设计</span>
                </a>
            </div>
            <!--//logo-->
            <div class="clearfix"></div>
        </div>
        <div class="header-right">
            <!--notification menu end -->
            <div class="profile_details">
                <ul>
                    <li class="dropdown profile_details_drop">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                            <div class="profile_img">
<!--                                <span class="prfil-img"><img src="images/fu.png" alt=""> </span>-->
                                <div class="user-name">
                                    <p>啊福</p>
                                    <span>管理员</span>
                                </div>
                                <i class="fa fa-angle-down lnr"></i>
                                <i class="fa fa-angle-up lnr"></i>
                                <div class="clearfix"></div>
                            </div>
                        </a>
                        <ul class="dropdown-menu drp-mnu">
                            <li><a href="#"><i class="fa fa-user"></i> 个人信息</a></li>
                            <li><a href="#"><i class="fa fa-sign-out"></i> 退出</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- //header-ends -->
    <!-- main content start-->
    <div id="page-wrapper">
        <div style="margin-bottom: 65px;display: flex;align-items: center;height: 40px">
            <input class="sb-search-input" style="width: 25%;margin-left: 10px;height: 100%" placeholder="Search..."
                   type="search" id="input-31"/>
            <h2 style="margin-left: 10px;height: 100%"><a href="#"><span class="label label-primary" data-toggle="modal" data-target="#myModal2" onclick=handleSearch(4)>查询</span></a></h2>
            <h2 style="margin-left: 10px;height: 100%"><a href="/access/exportAccess"><span class="label label-primary">导出报表</span></a>
            </h2>
        </div>
        <div class="main-page">
            <!--//end-search-box-->
            <div class="tables">
                <div class="panel-body widget-shadow">
                    <h4>门禁记录表:</h4>
                    <table class="table" id="carTable">
                        <thead>
                        <tr>
                            <th>车牌号</th>
                            <th>车位号</th>
                            <th>车位过期时间</th>
                            <th>用户id</th>
                            <th>社区id</th>
                        </tr>
                        </thead>
                        <!--                        <tbody>-->
                        <!--                        <tr>-->
                        <!--                            <th scope="row">1</th>-->
                        <!--                            <td>Mark</td>-->
                        <!--                            <td>Otto</td>-->
                        <!--                            <td>@mdo</td>-->
                        <!--                            <td>@mdo</td>-->
                        <!--                        </tr>-->
                        <!--                        <tr>-->
                        <!--                            <th scope="row">2</th>-->
                        <!--                            <td>Jacob</td>-->
                        <!--                            <td>Thornton</td>-->
                        <!--                            <td>@fat</td>-->
                        <!--                            <td>@mdo</td>-->
                        <!--                        </tr>-->
                        <!--                        <tr>-->
                        <!--                            <th scope="row">3</th>-->
                        <!--                            <td>Larry</td>-->
                        <!--                            <td>the Bird</td>-->
                        <!--                            <td>@twitter</td>-->
                        <!--                            <td>@mdo</td>-->
                        <!--                        </tr>-->
                        <!--                        </tbody>-->
                    </table>
                    <div id="page"></div>
                </div>
            </div>
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">用户信息</h4>
                        </div>
                        <div class="modal-body">

                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary">提交更改</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>

            <!-- 模态框 -->
            <div class="modal fade" id="myModal2">
                <div class="modal-dialog">
                    <div class="modal-content">

                        <!-- 模态框头部 -->
                        <div class="modal-header">
                            <h4 class="modal-title">车主信息</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>

                        <!-- 模态框主体 -->
                        <div class="modal-body">
                            <div class=" " style="display: flex;align-items: center">
                                <span>姓名:</span>
                                <input type="text" id="name">
                            </div>
                            <div class=" " style="display: flex;align-items: center">
                                <span>电话:</span>
                                <input type="text" id="userPhone">
                            </div>
                            <div class=" " style="display: flex;align-items: center">
                                <span>身份证:</span>
                                <input type="text" id="userIdcard">
                            </div>
                            <div class=" " style="display: flex;align-items: center">
                                <span>小区名称:</span>
                                <input type="text" id="communityName">
                            </div>
                        </div>

                        <!-- 模态框底部 -->
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">更新</button>
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--footer-->
    <script>
        let pageNum = 1
        let pagesize = 7

       function handleSearch(license) {
        $.ajax({
            url:'http://localhost:10080/access/getUserByAccessId?id='+license,
            type: 'get',
            success : handleUserForm
        })
       }

        function handleUserForm(res) {
            const data = res.data
            $('#name').val(data.userName),
                $('#userPhone').val(data.userPhone),
                $('#userIdcard').val(data.userIdcard),
                $('#communityName').val(data.communityName)



        }

        function handleChange(id) {

        }

        function handleDelete(id) {
            $.ajax({
                type: 'get',
                url: 'http://localhost:10080/access/deleteAccess?id=' + id

            })

        }

        function getPrevious(curr) {
            if (curr - 2 !== 1) {
                pageNum = curr - 1
                getCarPage()
            }
        }

        function getNext(curr, pages) {
            if (curr + 3 !== pages) {
                pageNum = curr + 1
                getCarPage()
            }
        }

        function getTable(res) {
            $('#page').empty()
            const data = res.data
            if (data.current + 2 <= data.pages) {
                $('#page').append(`
            <ul class="pagination pagination-lg">
                            <li><span  aria-label="Previous"><span aria-hidden="true" onclick="getPrevious(${data.current})">«</span></></li>
                            <li><span>首页</span></li>
                            <li><span>${data.current + 1}</span></li>
                            <li><span>${data.current + 2}</span></li>
                            <li><span >尾页</span></li>
                            <li><span  aria-label="Next"><span aria-hidden="true" onclick="getNext(${data.current},${data.pages})">»</span></span></li>
                        </ul>
            `)
            }
            $('#carTable').empty()
            $('#carTable').append(`
                <thead>
                        <tr>
                            <th>车牌号</th>
                            <th>创建时间</th>
                            <th>支付类型</th>
                            <th>社区名称</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="tbody"></tbody>
                `)
            $.each(data.records, function (index, item) {
                console.log(item)
                $('#tbody').append(`
                    <tr>
                            <th>${item.carLicense}</th>
                            <td>${item.createTime}</td>
                            <td>${item.orderState}</td>
                            <td>${item.communityName}</td>
                            <td>
<!--                                <span data-toggle="modal" data-target="#myModal" style="cursor: pointer;text-decoration: underline;margin-right: 5px" onclick="handleSearch1(${item.carLicense})">查询</span>-->
<!--                                <span style="cursor: pointer;text-decoration: underline" onclick="handleSearch(${item.accessId})">查询</span>-->

                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal2" onclick="handleSearch(${item.accessId} ">
                                                                 <span onclick="handleSearch(${item.accessId})">查询</span>
                                </button>
                                <button type="button" class="btn btn-primary"  onclick="handleDelete(${item.accessId})">删除</button>
                            </td>
                        </tr>
                    `)
            })
        }

        getCarPage()

        function getCarPage() {
            $.ajax({
                type: 'get',
                url: 'http://localhost:10080/access/getAccessPage',
                data: {
                    pageNum: pageNum,
                    pageSize: pagesize
                },
                dataType: 'json',
                success: getTable,
                error: function () {

                }
            });
        }
    </script>
    <!--//footer-->
</div>
<!-- Classie -->
<script src="/js/classie.js"></script>


<!--<script src="/js/jquery.nicescroll.js"></script>-->
<script src="/js/scripts.js"></script>
<!--//scrolling js-->
<!-- Bootstrap Core JavaScript -->
<script src="/js/bootstrap.js"></script>
</body>
</html>